package com.nanhai.buddhist.college.module.study.dal.mysql.studyplan;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.module.study.controller.admin.studyplan.vo.StudyPlanExportReqVO;
import com.nanhai.buddhist.college.module.study.controller.admin.studyplan.vo.StudyPlanPageReqVO;
import com.nanhai.buddhist.college.module.study.dal.dataobject.studyplan.StudyPlanDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 教学计划 Mapper
 *
 * @author xqenzo@163.com
 */
@Mapper
public interface StudyPlanMapper extends BaseMapperX<StudyPlanDO> {

    default PageResult<StudyPlanDO> selectPage(StudyPlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StudyPlanDO>()
                .eqIfPresent(StudyPlanDO::getCollegesId, reqVO.getCollegesId())
                .eqIfPresent(StudyPlanDO::getSchoolYear, reqVO.getSchoolYear())
                .eqIfPresent(StudyPlanDO::getSemester, reqVO.getSemester())
                .eqIfPresent(StudyPlanDO::getHierarchy, reqVO.getHierarchy())
                .eqIfPresent(StudyPlanDO::getClassesGrade, reqVO.getClassesGrade())
                .eqIfPresent(StudyPlanDO::getRemark, reqVO.getRemark())
                .eqIfPresent(StudyPlanDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StudyPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudyPlanDO::getCreateTime));
    }

    default List<StudyPlanDO> selectList(StudyPlanExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<StudyPlanDO>()
                .eqIfPresent(StudyPlanDO::getCollegesId, reqVO.getCollegesId())
                .eqIfPresent(StudyPlanDO::getSchoolYear, reqVO.getSchoolYear())
                .eqIfPresent(StudyPlanDO::getSemester, reqVO.getSemester())
                .eqIfPresent(StudyPlanDO::getHierarchy, reqVO.getHierarchy())
                .eqIfPresent(StudyPlanDO::getClassesGrade, reqVO.getClassesGrade())
                .eqIfPresent(StudyPlanDO::getRemark, reqVO.getRemark())
                .eqIfPresent(StudyPlanDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StudyPlanDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StudyPlanDO::getCreateTime));
    }

}
